<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>导航菜单</title>
</head>
<body>
<script type="text/javascript" th:fragment="commonJs" th:inline="javascript">
    /*<![CDATA[*/
    //let uri = "http://"+ [[${#httpServletRequest.getServerName()}]];
    //let port = [[${#httpServletRequest.getServerPort()}]];
    //let serverUri = uri + (isEmpty(port) ? "" : ":"+port);
    let Harin ={
        openLoyer1: function(){}
    };


    function dateChange(num = 1,date = false) {
        if (!date) {
            date = new Date();//没有传入值时,默认是当前日期
            //date = date.getFullYear() + '年' + (date.getMonth() + 1) + '月' + date.getDate()+"日";
            date = date.format("yyyy年MM月dd日");
        }
        date += " 00:00:00";//设置为当天凌晨12点
        date = Date.parse(new Date(date))/1000;//转换为时间戳
        date += (86400) * num;//修改后的时间戳
        var newDate = new Date(parseInt(date) * 1000);//转换为时间
        return newDate.format("yyyy年MM月dd日");
    }


    //JSON转GET请求参数
    function json_to_get(sstr){
        sstr = sstr.replace(/\t/g,"");
        sstr = sstr.replace(/\"/g,"").replace("{","").replace("}","").
            sstr = sstr.replace(",","&").replace(":","=");
        sstr = sstr.replace(/\"/g,"").replace(/{/g,"").replace(/}/g,"")
        sstr= sstr.replace(/,/g,"&").replace(/:/g,"=");
        return sstr;
    }
    //GET转JSON请求参数:
    function get_to_json(sstr){
        sstr = sstr.replace(/&/g,'","').replace(/=/g,'":"');
        sstr= '{"'+sstr+'"}';
    }

    //应该写在全局里
    function isEmpty(obj) {
        if (typeof obj == "undefined" || obj == null || obj == "") {
            return true;
        } else {
            return false;
        }
    }
    function openLayer(title,url,w,h,full,endFun){
        if (title == null || title == '') {
            var title=false;
        };
        if (url == null || url == '') {
            var url="404.html";
        };
        if (w == null || w == '') {
            var w=($(window).width()*0.9);
        };
        if (h == null || h == '') {
            var h=($(window).height() - 50);
        };
        var index = layer.open({
            type: 2,
            area: [w+'px', h +'px'],
            fix: false, //不固定
            maxmin: true,
            shadeClose: true,
            shade:0.4,
            title: title,
            content: url,
            end:endFun
        });
        if(full){
            layer.full(index);
        }
    }
    /**
     *调用打开弹窗的方法
     * title：弹窗标题
     * url:访问的url
     * w:弹窗宽
     * h:弹窗高
     * full:boolean 是否全屏显示
     * endFun:关闭弹窗执行的方法
     *
     */
    Harin.openLoyer1= function(title,url,w,h,full,endFun) {
        if (title == null || title == '') {
            let title=false;
        };
        if (url == null || url == '') {
            let url="404.html";
        };
        if (w == null || w == '') {
            let w=($(window).width()*0.9);
        };
        if (h == null || h == '') {
            let h=($(window).height() - 50);
        };
        let index = layer.open({
            type: 2,
            area: [w+'px', h +'px'],
            fix: false, //不固定
            maxmin: true,
            shadeClose: true,
            shade:0.4,
            title: title,
            content: url,
            end: endFun     //这里不能写成endFun(),会莫名其妙的打开前执行。坑！！！前端太差了

        });
        if(full){
            layer.full(index);
        }
    }
    //时间格式化
    Date.prototype.format = function (fmt) {
        let o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        for (let k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            }
        }
        return fmt;
    }
    /*]]>*/
</script>
</body>
</html>


